package compare

import (
	"awesomeProject2/download"
	"awesomeProject2/elm"
	"awesomeProject2/mt"
	"awesomeProject2/name"
	"awesomeProject2/time"
	"awesomeProject2/write_line"
	"strconv"
	"strings"
)

func CompareMt() {
	//nameselm := product.OpenNameLine("C:\\Users\\admin\\GolandProjects\\waimaigo\\elm\\产品.txt")
	//namesmt := product.OpenNameLine("C:\\Users\\admin\\GolandProjects\\waimaigo\\mt\\产品.txt")

	mtsMt := mt.GetFileMt()
	mtsElm := elm.GetFileElm()

	//sfc := make([]string, 0)
	//ecode := make([]string, 0)
	//names := make([]string, 0)
	//activityPrices := make([]string, 0)
	//prices := make([]string, 0)

	nonames := make([]string, 0)
	nocodes := make([]string, 0)
	noprices := make([]string, 0)
	noactivityprices := make([]string, 0)

	secound := time.GetTimeSecound()

	for _, products := range mtsMt {
		for _, datum := range products.Data.ProductList {
			titleMt := name.GetNameByTitle(datum.Name)
			nameMtNoName := titleMt + "====================="
			for _, productMt := range mtsElm {
				for _, datumElm := range productMt.Data.Data {
					//titleElm := name.GetNameByTitle(datumElm.Title)
					if datum.Name == datumElm.Title {
						nameMtNoName = datum.Name
					}
				}
			}
			if strings.Contains(nameMtNoName, "======") {
				println(nameMtNoName)
				nonames = append(nonames, datum.Name)
				noprices = append(noprices, strconv.FormatFloat(datum.WmProductSkus[0].Price, 'f', 2, 64))
				//noactivityprices = append(noactivityprices, strconv.FormatFloat(datum.MinActivePrice, 'f', 2, 64))
				//if datum.MinActivePrice == 0 {
				//	noactivityprices = append(noactivityprices, strconv.FormatFloat(datum.Price/2, 'f', 2, 64))
				//} else {
				//	noactivityprices = append(noactivityprices, strconv.FormatFloat(datum.MinActivePrice, 'f', 2, 64))
				//}
				nocodes = append(nocodes, strconv.Itoa(secound))
				secound = secound + 1
				download.Download(datum.Pictures[0], datum.Name)
			}
		}
	}

	write_line.WriteLineTxm(nocodes, "C:\\Users\\admin\\GolandProjects\\waimaigo\\mt\\elm_no_code.txt")
	write_line.WriteLineTxm(nonames, "C:\\Users\\admin\\GolandProjects\\waimaigo\\mt\\elm_no_names.txt")
	write_line.WriteLineTxm(noprices, "C:\\Users\\admin\\GolandProjects\\waimaigo\\mt\\elm_no_prices.txt")
	write_line.WriteLineTxm(noactivityprices, "C:\\Users\\admin\\GolandProjects\\waimaigo\\mt\\elm_no_activity_prices.txt")

	//write_line.WriteLineTxm(names, "C:\\Users\\admin\\GolandProjects\\waimaigo\\mt\\activity.txt")
	//write_line.WriteLineTxm(sfc, "C:\\Users\\admin\\GolandProjects\\waimaigo\\mt\\activity_code.txt")
	//write_line.WriteLineTxm(activityPrices, "C:\\Users\\admin\\GolandProjects\\waimaigo\\mt\\activity_price.txt")
	//write_line.WriteLineTxm(prices, "C:\\Users\\admin\\GolandProjects\\waimaigo\\mt\\prices.txt")
	//write_line.WriteLineTxm(ecode, "C:\\Users\\admin\\GolandProjects\\waimaigo\\mt\\ecode.txt")

}
